<?php

require_once 'lib.php';
$fp = new FlickrPhotosetsOther();
$fp->facebook->require_frame();
$fp->uid = $_GET['uid'];
$fp->get_info($fp->uid);

$fp->config['photosets'] = str_replace(',', ', ', $fp->config['photosets']);

$profile = $fp->facebook->api_client->profile_getFBML($fp->uid);
$start = strpos($profile, '<fb:wide>') + 9;
$end = strpos($profile, '</fb:wide>') - $start;
$profile_fbml = substr($profile, $start, $end);

$config = $fp->config;
$config['photosets'] = str_replace(',', ', ', $config['photosets']);
$config = str_replace("\n", '<br/>', print_r($config, true));
$config = str_replace(' ', '&nbsp;', $config);


?>

<style>
#content h2 { margin-top: 2em; margin-bottom: 1em; }
.overflow { overflow: auto; border: 1px solid #f7f7f7; }
.fixed { font-family: monospace; }
pre {
 white-space: pre-wrap;       /* css-3 */
}
</style>

<fb:title>Flickr Photosets Administration</fb:title>
<fb:header />
<div id="content" style="margin:20px;">
	<fb:if-is-user uid="1470030056">

		<h1>Information for <fb:name uid="<?=$fp->uid?>" useyou="false" /></h1>
		
		<h2>Configuration Information</h2>
		<div class="fixed">
			<?=$config?>
		</div>
		
		<h2>Profile Box (Current)</h2>
		<div style="width:380px;">
			<?=$profile_fbml?>
		</div>
		<p><a href="" clicktotoggle="profile_fbml">Show/hide FBML</a>
			<div style="display:none;" class="overflow" id="profile_fbml">
				<pre>
					<?=htmlentities($profile)?>
				</pre>
			</div>
		
		<h2>Profile Box (Updated)</h2>
		<fb:iframe src="<?=$fp->app_call_url?>/profile.php?handle=<?=$fp->uid?>" width="600" height="250" />

		<fb:else>
			<fb:error message="You don't have permission to view this page!" />
		</fb:else>
	</fb:if-is-user>
</div>